<?php 

class AdminModel extends Model{
	public $table='admin';
	public function __init()
	{
		
	}
	public function login($data)
	{
		if (empty($data['username'])) {
			$this->error='用户名不能为空';
			return false;
		}
		if (empty($data['password'])) {
			$this->error='密码不能为空';
			return false;
		}
		$user=$this->where(" username='{$data['username']}'")->find();
		if ($user['username']!=$data['username']) {
			$this->error='用户名不正确';
			return false;
		}
		//md5加密
		if ($user['password']!=$data['password']) {
			$this->error='密码不正确';
			return false;
		}
		$_SESSION['adid']=$user['adid'];
		$_SESSION['username']=$user['username'];
		return true;
	}
}

 ?>